PrototypeNice.Position = {
  WindowMethods: {
    getDimensions: function() {
      if (window.innerHeight) {
        return {width: window.innerWidth, height: window.innerHeight};
      }
      else if (document.documentElement && document.documentElement.clientHeight) {
        return {width: document.documentElement.clientWidth, height: document.documentElement.clientHeight};
      }
      else if (document.body) {
        return {width: document.body.clientWidth, height: document.body.clientHeight};
      }
    },
    getScrollOffset: function() {
      if (self.pageYOffset) {
        return {x: self.pageXOffset, y: self.pageYOffset};
      }
      else if (document.documentElement && document.documentElement.scrollTop) {
        return {x :document.documentElement.scrollLeft, y: document.documentElement.scrollTop};
      }
      else if (document.body) {
        return {x: document.body.scrollLeft, y: document.body.scrollTop};
      }
    }
  },
  ElementMethods: {
    centerToWindow: function(element, fix) {
      element = $(element);
      var elDimensions = element.getDimensions();
      var winDimensions = window.getDimensions();
      element.setStyle({
        top: (winDimensions.height - elDimensions.height) / 2 + 'px',
        left: (winDimensions.width - elDimensions.width) / 2 + 'px'
      });
    }
  }  
};
Object.extend(window, PrototypeNice.Position.WindowMethods); // Does this work in IE/Opera/Safari?
Element.addMethods(PrototypeNice.Position.ElementMethods);